const server = require("../../server/server.js");

Page({
    data: {
        dot: true,
        autopaly: true,
        time: 5000,
        loops:[],
        products:[]
    },
    onLoad:function(){
        wx.showLoading({
            title:"数据加载中",
            mask:true
        });
        Promise.all([
            this.loadLoopData(),
            this.loadProductList()
        ]).finally(wx.hideLoading());
    },
    loadLoopData:function(){
        return server.loadLoopList1()
        .then((data)=>{
            // console.log(data)
            this.setData({
                loops:data
            })
        })
        .catch((error)=>{
            console.log(error);
        })
    },
    loadProductList(){
        return server.loadProductList()
        .then((data)=>{
            // console.log(data)
            this.setData({
                products:data.rows
            })
        })
        .catch((error)=>{
            console.log(error);
        })
    },
    onPullDownRefresh(){
        this.loadProductList();
    }
});